|
|
|
|
|
|
|
Now, heres a practical example using the Employee Information form. Check out the standard module Vars.bas to see the following declaration: |
|
|
|
 |
|
|
|
|
Public Type Employee_Type
strSSN As String
strFirst As String
strLast As String
strStreet As String
strCity As String
strState As String
strZip As String
curSalary As Currency
boolBonus As Boolean
End Type |
|
|
|
|
|
|
|
|
As you can see, this data type is now made up of many different string variables, a currency variable, and a Boolean variable. However, each element can only be referenced through a variable declared to be of type Employee_Type. |
|
|
|
|
|
|
|
|
The Type declaration, by itself, is just a template of what this data type will look like. To use it, you must declare a Private or Public variable as Employee_Type: |
|
|
|
 |
|
|
|
|
Private mtypEmp As Employee_Type |
|
|
|
|
|
|
|
|
After youve created this new variable, you can set the individual elements of this type, just like you set properties for a control or a form: |
|
|
|
 |
|
|
|
|
mtypEmp.strFirst = "Bill"
mtypEmp.strLast = "Gates"
mtypEmp.curSalary = 1000000
mtypEmp.boolBonus = True |
|
|
|
|
|
|
|
|
Lets take the Employee Information form you created in a previous chapter and load the data from the form into this structure (see Figure 7.3). |
|
|
|
|
|